package com.jh.user.controller.model;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Range;
import com.jh.user.pojo.ThirdPayRate;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author Yichuan
 * @version 1.0
 */
public class ProfitRateVO implements Serializable {

    private static final long serialVersionUID = -9215317612065360178L;

    public static ProfitRateVO from(ThirdPayRate payRate) {
        return new ProfitRateVO(payRate.getType().getValue(), payRate.getRangeData());
    }

    public static List<ProfitRateVO> from(List<ThirdPayRate> payRateList) {
        if (payRateList == null || payRateList.isEmpty()) {
            return ImmutableList.of();
        }
        return payRateList.stream().map(ProfitRateVO::from).collect(Collectors.toList());
    }

    private String type;
    private Map<Range<BigDecimal>, BigDecimal> rateData;

    public ProfitRateVO() {
        super();
    }

    public ProfitRateVO(String type, Map<Range<BigDecimal>, BigDecimal> rateData) {
        this.type = type;
        this.rateData = rateData;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Map<Range<BigDecimal>, BigDecimal> getRateData() {
        return rateData;
    }

    public void setRateData(Map<Range<BigDecimal>, BigDecimal> rateData) {
        this.rateData = rateData;
    }
}
